﻿using System.Xml.Serialization;
public static class CommonExtensions
{
    public static T Deserialize<T>(this string content)
    {
        var serializer = new XmlSerializer(typeof(T));
        var reader = new System.IO.StringReader(content);
        try
        {
            return (T)serializer.Deserialize(reader);
        }
        catch
        {
            return default(T);
        }
    }
    public static string Serialize<T>(this T me) where T : class
    {
        var serializer = new XmlSerializer(typeof(T));
        var builder = new System.Text.StringBuilder();
        var writer = new System.IO.StringWriter(builder);

        serializer.Serialize(writer, me);
        return builder.ToString();
    }
}
